iT邦幫忙

0

[Pytorch] torchvision.transforms()

  • 分享至 

  • xImage
  •  
  • torchvision.transforms()
  1. Transforms are common image transformations.
  2. They can be chained together using Compose.
  3. Functional transforms give fine-grained control over the transformations.
  • Chained with multiple transform. Thus, transforms is composed of transform.
    transforms.Compose([
    transforms.CenterCrop(10),
    transforms.Normalize((0.5, 0.4, 0.5), (0.5, 0.5, 0.5)),
    transforms.RandomHorizontalFlip(p=0.5),
    transforms.RandomRotation(),
    transforms.RandomApply(random_transforms, p=0.3),
    transforms.ToTensor()
 ])
  • class torchvision.transforms.Scale(size, interpolation=2)
# No contents yet
  • class torchvision.transforms.RandomCrop(size, padding=0)
    Crop the given PIL image at a random location.

  • class torchvision.transforms.RandomHorizontalFlip(p=0.5)
    Horizontally flip the given image randomly with a given probability.

  • class torchvision.transforms.RandomRotation

  • class torchvision.transforms.Resize(size)
    Resize the input PIL image to the given size, usually used with training_testing set

  • class torchvision.transforms.RandomApply

  • class torchvision.transforms.ToTensor

  • class torchvision.transforms.Normalize(mean, std)
    Only use Normalize with Tensor, not PIL.image

  • class torchvision.transforms.ToTensor // HWC > CHW
    Convert PIL.image to Tensor

Converts a PIL Image or numpy.ndarray (H x W x C) in the range [0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0].

C: Channels, H: Heights, W: Widths
  • class torchvision.transforms.ToPILImage(mode=None) // CHW > HWC
    Convert Tensor to PIL.image

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言